<template>
<h3>子组件事件：demo08-event03-component-children02.vue</h3>
  <form>
    <p class="zhtt-line">
      <input type="text" class="zhtt-input" v-model="email">
    </p>
    <p class="zhtt-line">
      <input type="text" class="zhtt-input" v-model="password">
    </p>
    <button class="zhtt-btn" @click="submitForm">点击测试</button>
  </form>
</template>

<script>
export default {
  data(){
    return {
      email:null,
      password:null
    }
  },
  emits: {
    // 验证 submit 事件
    submit: ({ email, password }) => {
      if (email && password) {
        return true
      } else {
        console.warn('Invalid submit event payload!')
        return false
      }
    }
  },
  methods: {
    submitForm() {
      this.$emit('submit', { email: this.email, password: this.password })
    }
  }
}
</script>